<?php
	require_once 'models/models_chitietnhap.php';
	$mod = $_GET['mod'];
	$obctnhap = new models_chitietnhap();
	require_once 'models/models_ncc.php';
	$obncc = new models_ncc();
	require_once 'models/models_mathang.php';
	$obMh = new  models_mathang();
	switch ($mod){
		case 'ctnhap':{
			$data['list'] = $obctnhap->_listCTNhap();
			$data['listncc'] = $obncc->_listncc();
			$data['listmathang'] = $obMh->listMatHang();
			require 'views/admin/chitietnhap/index.php';
			break;
		}
		case 'add_ctnhap':{
			if($_POST){
				$obctnhap->_addCTNhap($_POST['cmb_ncc'], $_POST['cmb_mathang'], $_POST['dongia'], $_POST['soluong'], $_POST['ngaynhap']);
				echo '<script>window.location.href="admin.php?mod=ctnhap"</script>';
			}
			$listncc['list'] = $obctnhap->_getncc();
			$listmathang['list'] = $obctnhap->_getMatHang();
			require 'views/admin/chitietnhap/add.php';
			break;
		}
		case 'del_ctnhap':{
			$obctnhap->_delCTNhap($_GET['id']);
			echo '<script>window.location.href="admin.php?mod=ctnhap"</script>';
			break;
		}
		case 'edit_ctnhap':{
			if($_POST){
				$obctnhap->_editCTNhap($_POST['cmb_ncc'], $_POST['cmb_mathang'], $_POST['dongia'], $_POST['soluong'],$_GET['id']);
				echo '<script>window.location.href="admin.php?mod=ctnhap"</script>';
			}
			$data = $obctnhap->_getCTNhap($_GET['id']);
			$data['listncc'] = $obncc->_listncc();
			$data['listmathang'] = $obMh->listMatHang();
			require 'views/admin/chitietnhap/edit.php';
			break;
		}
	}
?>